/**
 * Created by thomas on 2017/12/2.
 */
'use strict';

var gulp = require('gulp');
var sass = require('gulp-sass');
var connect = require('gulp-connect');//livereload
var minifyCss = require("gulp-minify-css");
var proxy = require('http-proxy-middleware');

gulp.task('sass', function () {
    return gulp.src('./sass/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(minifyCss().on("error",function(e){
            console.log(e);
        }))
        .pipe(gulp.dest('./css'));
});


gulp.task('sass:watch', function () {
    gulp.watch('./sass/**/*.scss', ['sass']);
});

gulp.task('connect',function(){
    connect.server({
        root: '',
        port: 8011,
        livereload: true,
        middleware: function(connect, opt) {
            return [
                proxy('/yizhiweimen', {
                    target: 'https://wx.yizhiweimeng.com/',
                    changeOrigin: true
                })
            ]
        }
    });
});

gulp.task('default',["connect","sass:watch"]);